package ATM;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Mun extends JPanel implements ActionListener {
    private JButton getmony; //取钱
    private JButton savemony; //存钱
    private JButton check; //查询
    private JButton returnBut; //返回
    private Atm frame;


    public Mun(Atm frame) {
        //返回登陆界面
        this.frame = frame;
        this.setLayout(null);
        returnBut = new JButton("返回");
        returnBut.setBounds(350,280,140,50);
        this.add(returnBut);
        returnBut.addActionListener(this);

        //存款按钮
        savemony = new JButton("存款");
        savemony.setBounds(100, 50, 100, 50);
        this.add(savemony);
        savemony.addActionListener(this);

        //取款按钮
        getmony=new JButton("取款");
        getmony.setBounds(240,200,100,50);
        this.add(getmony);
        getmony.addActionListener(this);

        //查询按钮
        check=new JButton("查询");
        check.setBounds(340,200,100,50);

    }


    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == returnBut) {
            frame.switchPanel("登陆");
        }else if (e.getSource()==savemony){
            frame.switchPanel("存款");
        }else if (e.getSource()==getmony){
            frame.switchPanel("取款");
        }else if (e.getSource()==check){
            frame.switchPanel("查询");
        }

    }

}

